package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author 快点干早点散
 * @Create 2025/3/28 14:10
 * Description:
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result exception(Exception e) {
        e.printStackTrace(); //打印异常信息
        System.out.println("e = " + e);
        return Result.fail();
    }
//    @ExceptionHandler(LeaseException.class)
//    public  Result leaseException(LeaseException e){
//        e.printStackTrace();
//        return Result.build(e.getCode(),e.getMessage());
//    }
    @ExceptionHandler(LeaseException.class)
    public Result  leaseExecption(LeaseException e){
        e.printStackTrace();
        return  Result.build(e.getCode(),e.getMessage());

    }

}
